package com.liaoct.lct.listener;

import java.util.List;

import com.liaoct.lct.activity.BaseActivity;
import com.liaoct.lct.activity.R;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/**
 * 选项卡菜单按钮点击事件
 * 
 * @author liaoct
 * 
 */
public class TabMenuButtonClickListener implements OnClickListener {

	private BaseActivity activity;

	private int index;

	private List<Button> btnList;

	public TabMenuButtonClickListener(int index, BaseActivity activity,
			List<Button> btnList) {
		this.index = index;
		this.activity = activity;
		this.btnList = btnList;
	}

	@Override
	public void onClick(View v) {
		activity.performTranscation(index);
		for (int i = 0; i < btnList.size(); i++) {
			Button btn = btnList.get(i);
			if (i == index) {
				btn.setBackgroundResource(R.drawable.button_active);
				activity.getAppHeader().setText(btn.getText());
			} else {
				btn.setBackgroundResource(R.drawable.button_unfocus);
			}
		}
	}
}
